<%@ taglib prefix="page" uri="http://com.qipay/pagelib" %>
<%@ page language="java" import="com.qipay.admin.withdraw.vo.WithdrawVo" contentType="text/html;charset=utf-8" %>
<%@ page import="com.qipay.admin.tags.PageModel" %>
<%@ page import="com.qipay.admin.utils.SiteHelper" %>
<%@ page import="com.qipay.user.entity.UserLevel" %>
<%@ page import="org.apache.commons.collections.CollectionUtils" %>
<%@ page import="java.util.List" %>
<%@ page import="com.qipay.withdraw.config.WithdrawStateEnum" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.qipay.configuration.config.ConfigurationEnum" %>
<%@ page import="org.apache.commons.lang3.StringUtils" %>
<%@ page import="com.qipay.admin.withdraw.vo.CountWithdrawInfoVo" %>
<!doctype html>
<html>
<head>
    <jsp:include page="head.jsp"></jsp:include>
    <link rel="stylesheet" href="<%= request.getAttribute("StaticHost") %>/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" href="<%= request.getAttribute("StaticHost") %>/css/bootstrap-datepicker3.min.css">

</head>
</head>
<body class="devpreview hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <jsp:include page="nav.jsp"></jsp:include>
    <jsp:include page="left.jsp"></jsp:include>
    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <section class="content-header">
            <h3 class="box-title">节假日操作</h3>
        </section>
        <section class="content">
            <div class="row box box-warning">
                <div class="box-header">
                    <h3 class="box-title">导出</h3>
                </div>
                <div class="box-body">
                    <form id="searchForm" class="form-inline">
                        <div class="form-group date form_datetime">
                            <label for="year">年份：</label>
                            <input type="text" class="form-control" id="year" name="year" readonly
                                   value="">
                        </div>
                        <a href="" class="btn btn-success" id="btnDownload" download="节假日.xls"
                           target="_blank">导出</a>
                    </form>
                </div>
            </div>
            <div class="row box box-danger">
                <div class="box-header">
                    <h3 class="box-title">导入</h3>
                </div>
                <div class="box-body">
                    <form class="form-inline">
                        <div class="item">
                            <p class="message">参考：<a href="https://publicholidays.cn/zh" target="_blank" style="color: #00a65a;">https://publicholidays.cn/zh</a>
                            </p>
                            <p class="message">官网：<a href="http://www.gov.cn/guowuyuan/index.htm" target="_blank" style="color: #00a65a;">http://www.gov.cn/guowuyuan/index.htm</a>
                            </p>
                            <p class="message">搜索条件：</p>
                            <p class="message text-green" >&nbsp;&nbsp;&nbsp;关键字：<b style="color: #00a65a;">节假日</b>&nbsp;<b style="color: #00a65a;">2018</b></p>
                            <p class="message text-green" >&nbsp;&nbsp;&nbsp;类型：<b style="color: #00a65a;">国务院文件</b></p>
                        </div>
                        <input name="file" type="file" class="form-control" id="xls" placeholder="节假日.xls"
                               onchange="upload(this)">
                    </form>
                </div>
            </div>
            <div class="row box box-success">
                <div class="box-header">
                    <h3 class="box-title">查询指定日期是否是节假日</h3>
                </div>
                <div class="box-body">

                    <form class="form-inline">
                        <div class="form-group date form_datetime">
                            <label for="day">日期：</label>
                            <input type="text" class="form-control" id="day" name="day" readonly
                                   value="">
                        </div>
                        <button id="btnCheck" type="button" class="btn btn-success">查询</button>
                    </form>
                </div>
            </div>
        </section>
    </div>

    <%--<jsp:include page="foot.jsp"></jsp:include>--%>
    <script src="<%= request.getAttribute("StaticHost") %>/js/jquery.ajaxfileupload.js"></script>
    <script src="<%= request.getAttribute("StaticHost") %>/js/bootstrap-datepicker.min.js"></script>
    <script src="<%= request.getAttribute("StaticHost") %>/js/bootstrap-datepicker.zh-CN.min.js"></script>
    <script src="<%= request.getAttribute("StaticHost") %>/js/dataTables.bootstrap.min.js"></script>
    <script src="<%= request.getAttribute("StaticHost") %>/js/adminlte.min.js"></script>

    <script>
        $(function () {
            $('#year').datepicker({
                minViewMode: 2,
                setDate: new Date(),
                format: "yyyy",
                todayBtn: false,
                clearBtn: false,
                language: "zh-CN"
            });
            $('#day').datepicker({
                setDate: new Date(),
                format: "yyyy-mm-dd",
                todayBtn: true,
                clearBtn: false,
                language: "zh-CN"
            });
            initDownload();
        });

        $("#searchForm input, #searchForm select").change(initDownload);
        function initDownload() {
            $("#btnDownload").attr("href", "/holiday/export?" + $("#searchForm").serialize());
        }

        function upload(filepath) {
            var file = $.trim($(filepath).val());
            if (file == "") {
                alert("请选择文件");
                return;
            }
            if (null != file) {
                var extIdx = file.lastIndexOf(".");
                var ext = file.substr(extIdx + 1, file.length - extIdx).toLowerCase();
                if (ext.startsWith("xls")) {
                    $.ajaxFileUpload({
                        url: '${pageContext.request.contextPath}/holiday/upload?r=' + Math.random(),
                        secureuri: false,
                        fileElementId: filepath.id,
                        dataType: 'json',
                        success: function (data) {
                            if (data && data.code == "200") {
                                alert("上传成功")
                            }
                            else {
                                alert("上传失败:" + data.msg);
                            }
                        },
                        error: function (data, status, e) {
                            alert("error:" + data);
                        }
                    });
                }
                else {
                    alert("文件格式错误");
                    return;
                }
            }
        }

        $("#btnCheck").on("click", function () {

            // check
            var day = $("#day").val();
            if ("" == day) {
                alert("请选择要查询的日期");
                return;
            }

            // query
            $.get("/holiday/check?date=" + day, function (data) {
                if (null != data && data.code == 200) {
                    alert("查询成功：" + day + "= " + data.data);
                } else {
                    alert("查询失败：" + data.msg);
                }
            })
        });
    </script>
</body>
</html>

